package com.baizhi.service.impl;

import com.baizhi.dao.GurnDao;
import com.baizhi.entity.Gurn;
import com.baizhi.service.GurnService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class GurnServiceImpl implements GurnService {
    @Resource
    private GurnDao gurnDao;
    @Override
    @Transactional(readOnly = true)
    public PageInfo<Gurn> selectAll(Integer page, Integer limit, String guruName) {
        PageHelper.startPage(page,limit);
        PageInfo<Gurn> pageInfo = new PageInfo<>(gurnDao.selectAll(guruName));
        return pageInfo;
    }

    @Override
    public void insert(Gurn gurn) {
        gurnDao.insert(gurn);
    }

    @Override
    public void update(Integer guruStatus, Integer guruId) {
        gurnDao.update(guruStatus,guruId);
    }

    @Override
    public List<Gurn> showAll(String name) {
        return gurnDao.selectAll(name);
    }
}
